﻿Option Strict On
Option Explicit On

Partial Class private_secure_admin_efwd
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        Dim strGuidRef As String = ""
        Dim strCategory As String = ""
        If Not Request.QueryString("ref") Is Nothing Then
            strGuidRef = Request.QueryString("ref")
            strCategory = Request("cat")

            Try
                Dim strForwardLink As String = ""

                Try
                    Dim efwd As New LogginsLogDSTableAdapters.SPTableAdapter
                    efwd.usp_eForward_UpdateAndGet(strGuidRef, strCategory, strForwardLink)
                    If Not strForwardLink Is Nothing Then
                        Response.Redirect(strForwardLink)
                        'Server.Transfer(strForwardLink)
                    End If

                Catch ex As Exception
                    Dim str As String = ex.Message
                    'Throw ex
                End Try

            Catch ex As Exception
                Dim str As String = ex.Message
                'Throw ex

            End Try
        End If
    End Sub
    Public Function ExecuteNonQuery(ByVal query As String, ByVal oRetval As Object, ByVal ParamArray parameters() As SqlParameter) As Integer
        Dim strConnString As String = ConfigurationManager.ConnectionStrings("ApplicationServices").ConnectionString
        Dim cnn As SqlConnection = New SqlConnection(strConnString)
        Dim cmd As SqlCommand = New SqlCommand(query, cnn)
        If query.StartsWith("INSERT") Or query.StartsWith("insert") Or query.StartsWith("UPDATE") Or query.StartsWith("update") Or query.StartsWith("DELETE") Or query.StartsWith("delete") Then
            cmd.CommandType = CommandType.Text
        Else
            cmd.CommandType = CommandType.StoredProcedure
        End If
        For i As Integer = 0 To parameters.Length - 1
            cmd.Parameters.Add(parameters(i))
        Next

        ' Added error handling capability 30-May-2007
        Dim retval As Integer = 0
        Try
            cnn.Open()
            retval = cmd.ExecuteNonQuery()
            oRetval = CType(cmd.Parameters.Item("@ReturnValue").Value, Object)

        Catch sqlex As SqlException
            If (sqlex.Number <> 2627) Then
                Throw sqlex
            End If
        Catch exp As Exception
            'Call AddToErrorLog("SQLHelper.ExecuteNonQueryParams", exp.Source, exp.Message)
            Throw exp
        Finally
            If cnn.State = ConnectionState.Open Then
                cnn.Close()
            End If
        End Try
        Return retval

    End Function
End Class
